<template>
	<view class="address-item" @click="toCommit">
		<view class="address-info">
			<view class="user-info">
				<text class="name">{{item.name}}</text>
				<text class="phone">{{item.mobile}}</text>
				<text class="def" v-if="item.def">默认</text>
			</view>
			<view class="detail" v-if="!sale">
				{{item.province}}{{item.city}}{{item.county}}{{item.detail}}
			</view>
			<view class="detail" v-else>
				{{item.near}}{{item.detail}}{{item.house}}
			</view>
		</view>
		<view class="edit" @click.stop="toEdit">
			编辑
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			item:Object,
			edit:Boolean,
			sale:false
		},
		methods:{
		   toEdit(){
			   if(this.sale){
				   this.$Router.push({
				   				   path:"/pages/sale/address-edit",
				   				   query:{id:this.item.id}
				   })
			   }else{
				   this.$Router.push({
				   				   path:"/pages/address/edit",
				   				   query:{id:this.item.id}
				   })
			   }
		   },
			toCommit(){
				if(this.edit){
					return
				}
				let pages = getCurrentPages();
				    var prevPage = pages[pages.length - 2];  //上一个页面
				    prevPage.$vm.addressId= this.item.id
					this.$Router.back()
			}
		},
		data() {
			return {
				
			};
		}
	}
</script>

<style lang="stylus" scoped>
		.address-item
			 // border-radius 10upx
			 background-color #FFFFFF
			 height 170upx
			 display flex
			 padding 0 48upx 
			 align-items center
			 padding-right 0
			.edit
				height 80upx;
				font-size 24upx
				display flex
				align-items center
				color #A9B1C0
				justify-content center
				border-left 1px solid #A9B1C0
				margin-left 96upx
				flex 1
			.address-info
				width 423upx
				display flex
				flex-direction column
				justify-content center
				.user-info
					margin-bottom 23upx
					display flex
					align-items center
					.name
						font-size 28upx
						color #4E3D07
						margin-right 25upx
						line-height 28upx
					.phone
						color #A1A1A1
						font-size 24upx
					.def
						color #F7895E
						font-size 22upx
						padding 0upx 14upx
						background-color #FCE5DB
						margin-left 10upx
				.detail
					text-overflow ellipsis
					line-clamp 2
					overflow hidden
					font-size 22upx
					color #4E3D07
</style>
